//
//  LoginView.swift
//  SwiftUIExample
//
//  Created by qingzhou on 2021/6/20.
//

import SwiftUI

@available(iOS 15.0, *)
struct LoginView: View {
    
    enum Field {
        case name
        case password
        case verityCode
    }
    
    @State var name:String = ""
    @State var password:String = ""
    
    
    @FocusState private var focusedField: Field?
    
    var body: some View {
        VStack {
            TextField("请输入你的姓名",text: $name)
                .focused($focusedField,equals: .name)
                .textContentType(.givenName)
                .submitLabel(.next)
            SecureField("密码",text: $name)
                .onSubmit {
                    guard name.isEmpty == false && password.isEmpty == false else {return}
                    print("tt")
                }
            }
        }
}
//@available(iOS 15.0, *)
//extension LoginView {
//    func tfview() {
//        TextField(
//                "User name (email address)",
//                 text: name
//            ) { isEditing in
//                self.isEditing = isEditing
//            } onCommit: {
//                validate(name: name)
//            }
//            .autocapitalization(.none)
//            .disableAutocorrection(true)
//            .border(Color(UIColor.separator))
//            Text(name)
//                .foregroundColor(isEditing ? .red : .blue)
//    }
//}

@available(iOS 15.0, *)
struct LoginView_Previews: PreviewProvider {
    static var previews: some View {
            LoginView()
    }
}
